﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Resources;
using System.Text;
using System.Windows.Forms;

namespace 语音朗读机器人
{
    public partial class Installer : Form
    {
        public Installer()
        {
            InitializeComponent();
        }

        private void Installer_Load(object sender, EventArgs e)
        {
            Install(this.progressBar1);
        }
        private string pre_path = AppDomain.CurrentDomain.BaseDirectory;
        const string SYS = "hci_sys";
        const string TTS = "hci_tts";
        const string CS = "hci_tts_cloud_synth";
        const string LS = "hci_tts_local_synth";
        const string JTOPUS = "jtopus";
        const string JTSPEEX = "jtspeex";
        const string CURL = "libhci_curl";
        public void Install(ProgressBar pbr)
        {
            button1.Enabled = false;
            ResourceManager rm = new ResourceManager(typeof(Properties.Resources));
            pbr.Maximum = 7;
            System.IO.File.WriteAllBytes(pre_path + SYS + ".dll", (Byte[])rm.GetObject(SYS));
            pbr.Value++;
            System.IO.File.WriteAllBytes(pre_path + TTS + ".dll", (Byte[])rm.GetObject(TTS));
            pbr.Value++;
            System.IO.File.WriteAllBytes(pre_path + CS + ".dll", (Byte[])rm.GetObject(CS));
            pbr.Value++;
            System.IO.File.WriteAllBytes(pre_path + LS + ".dll", (Byte[])rm.GetObject(LS));
            pbr.Value++;
            System.IO.File.WriteAllBytes(pre_path + JTOPUS + ".dll", (Byte[])rm.GetObject(JTOPUS));
            pbr.Value++;
            System.IO.File.WriteAllBytes(pre_path + JTSPEEX + ".dll", (Byte[])rm.GetObject(JTSPEEX));
            pbr.Value++;
            System.IO.File.WriteAllBytes(pre_path + CURL + ".dll", (Byte[])rm.GetObject(CURL));
            pbr.Value++;
            button1.Enabled = true;
        }
        private void button1_Click(object sender, EventArgs e)
        {
            Environment.Exit(0);
        }
    }
}
